<template>
  <div class="box">
    <!--animated fadeInLeft rotateInDownLeft flip lightSpeedIn rollIn-->
    <transition>
      <div id="zuo" class="left" v-show="isfalse">
        <div class="img">
          <img src="../assets/logo.png" />
        </div>
        <div class="left-button">
          <ul class="ul">
            <li
              class="hide"
              :id="['hide'+ index]"
              v-for="(items,index) in $router.options.routes"
              :key="index"
              v-show="!items.hide"
              @click.self="change(index)"
            >
              <span class="span1">@</span>
              <span class="span2">{{items.name}}</span>
              <!-- rotateIn flip fadeInUpBig rollIn-->
              <ul class="fav1 animated flip">
                <div
                  @click="dianli(subm.name)"
                  class="fav1-div"
                  v-for="(subm, index) in items.children"
                  :key="index"
                >{{subm.name}}</div>
              </ul>
            </li>
          </ul>
        </div>
      </div>
    </transition>
    <div class="right">
      <div class="top">
        <button @click="show">显示/隐藏</button>
        <div class="top-right">
          <div class="img1">
            <img src="../assets/1.jpg" />
          </div>
          <span>{{$route.params.user}}</span>
          <el-button class="btn" type="primary" @click="add">退出</el-button>
        </div>
      </div>
      <div class="right-button">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
import Animate from "animate.css";
export default {
  data() {
    return {
      isfalse: true,
      isshow: false,
      list: [
        {
          name: "我的信息"
        },
        {
          name: "我的等级"
        }
      ]
    };
  },
  methods: {
    dianli(name){
      const user1 = this.$route.params.user;
      this.$router.push({ name, params: { user1 } })
    },
    change(index) {
      document.getElementById("hide" + index).classList.toggle("hide");
      this.$router.push({ name: "houtai" }).catch(() => {
        console.log("路由推了两次");
      });
      // this.menus[index].hide = !this.menus[index].hide;
    },
    show() {
      this.isfalse = !this.isfalse;
    },
    add(){
      this.$router.push({name:'HelloWorld'})
    }
  }
};
</script>

<style scoped>
.v-enter,
.v-leave-to {
  opacity: 0;
  transform: translateX(50px);
}
.v-enter-active,
.v-leave-active {
  transition: all 0.4s ease-in;
}

.zuo {
  display: none;
}
.fav1 {
  margin: 0px;
  padding: 0px;
}
.fav1-div {
  width: 100%;
  height: 30px;
  line-height: 30px;
  font-size: 12px;
  margin-top: 5px;
  text-align: center;
  margin-bottom: 10px;
  /* background-color: red; */
}
.fav1-div:hover {
  background-color: green;
  transition: all 0.4s ease-in;
}
.hide > ul {
  display: none;
}
.box {
  display: flex;
  background-color: #f7f7f7;
  width: 100%;
  height: 100%;
  /* margin-top: -60px; */
}
.left {
  width: 230px;
  height: 700px;
  background-color: #344a5f;
}
.img {
  padding-top: 20px;
  margin: auto;
  width: 80px;
  height: 80px;
}
.img img {
  width: 100%;
  height: 100%;
}
/* --------------left_button------------------- */
.ul {
  list-style-type: none;
  color: white;
  margin: 0px;
  padding: 0px;
}
.ul li {
  margin-top: 10px;
  width: 100%;
  /* height: 40px; */
  line-height: 40px;
  font-size: 14px;
  /* background-color: red; */
}
.ul li:hover {
  /* #41B883 */
  background-color: rgba(65, 148, 131, 0.8);
  transition: all 0.4s ease-in;
  cursor: pointer;
}

.span1 {
  margin-left: 20px;
  margin-right: 6px;
}
/* .fav1 {
  margin: 0px;
  padding: 0px;
  list-style-type: none;
  margin-left: 10px;
}
.fav1 li {
  margin-top: 20px;
  width: 100%;
  height: 40px;
  line-height: 40px;
  font-size: 14px;
} */

/* -----------top-------------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 50px;
  text-align: left;
  background-color: #ffffff;
  box-shadow: 0px 1px 8px black;
}
.top button {
  margin: 14px;
}
.top-right {
  display: flex;
  align-items: center;
  width: 260px;
  height: 100%;
  /* margin-right: 60px; */
}
.img1 {
  width: 30px;
  height: 30px;
}
.img1 img {
  border-radius: 20px;

  width: 100%;
  height: 100%;
}
.top-right span {
  font-size: 12px;
  margin-left: 10px;
}
/* -----------right------------- */
.right {
  width: 100%;
  height: 700px;
  /* background-color: red; */
}
.right-button {
  width: 96%;
  height: 89%;
  margin-left: 2%;
  margin-top: 2%;
  background-color: #ffffff;
}
</style>
